/*=+--+=#=+--     Unmanned Aerial System Management Software      --+=#=+--+=#*\
|          Copyright (C) 2011 Regents of the University of Colorado.           |
|                             All Rights Reserved.                             |

     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.

            Jack Elston                       Cory Dixon                        
|           elstonj@colorado.edu              dixonc@colorado.edu              |
|                                                                              |
\*=+--+=#=+--                 --+=#=+--+=#=+--                    --+=#=+--+=#*/

#ifndef _ANT_PAGE_H
#define _ANT_PAGE_H

#include "NodePages.h"
#include "myStripChart.h"

class AntPage : public NodePage
{
	public:
		virtual void update();
		virtual bool create_page(Client *client, GtkBuilder *builder);
		virtual void setCMD_RX(uint8_t cmd_id, int ack_nack=-1);

	protected:
		//--------------------PAGE VARIABLES--------------------//
		float track_range;
		GtkStripChart * range_graph;

		//-- display --//
		//   in this section, add the names of the widgets you designed
		//   in glade for the page you are creating
		GtkWidget *node_to_track;
		GtkWidget *antenna_track_range;
		float ant_ranges[MAX_CLIENTS];

		//-- input entry --//
		//  in this section, add any input boxes you gave to the user
		//  for input selection, can be buttons, text input, check boxes, ...
		GtkWidget *ant_start_button;
		GtkWidget *ant_stop_button;
		GtkWidget *ant_home_button;
		
		GtkWidget *ant_az;
		GtkWidget *ant_el;
		void update_ant_state();

		GtkWidget *ant_offset;
		GtkWidget *ant_offset_button;

		//-- callbacks --//
		//  in this section, add any of the callbacks you need to handle
		//  user input. Note, more than likely these will need to be static functions.
		//  Also, for the pointer we pass the WindowStruct pointer, which provides
		//  all the inormatio necessary to dray any/all pages
		
		// starting tracking with selected nodes
		static void ant_start_clicked(GtkButton *widget, gpointer data); 
		// stop tracking and clear selected nodes
		static void ant_stop_clicked(GtkButton *widget, gpointer data); 
		static void ant_home_clicked(GtkButton *widget, gpointer data); 
		static void ant_offset_clicked(GtkButton *widget, gpointer data); 

		// select / unselect a node
		static void item_toggled(GtkCellRendererToggle *cell, gchar *path_str, gpointer data);

		//-- Command buttons --//
		void send_track_cmd();
		void send_stop_track_cmd();
		void send_launch_cmd();
		void send_settings_cmd();

		//-- Track tree view --//
		GtkListStore * list_store;
		GtkTreeView  * treeview;

		void format_treeview(); // this formats the columns
		void create_node_range_tree(); // creates the list model
		void update_ant_pattern(); // updates the pattern from a client
		void update_gps_list(); // update the values in the tree model
};
#endif
